﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework5
{
    public class OrderDetails
    {
        private Goods goods;
        private double money;

        public OrderDetails()
        {
        }

        public OrderDetails(Goods goods)
        {
            this.goods = goods;
            money=goods.Price*goods.Num;
        }

        public Goods Good
        {
            get { return goods; }
            set { goods = value; }
        }
        public double Money
        {
            get { return money; }
            set { money = value; }
        }

        public override bool Equals(object obj)
        {
            var details = obj as OrderDetails;
            return details != null &&
                   goods == details.Good &&
                   money == details.Money;
        }

        public override int GetHashCode()
        {
            var hashCode = -2061905238;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Good.ToString());
            hashCode = hashCode * -1521134295 + money.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Good.ToString());
            hashCode = hashCode * -1521134295 + Money.GetHashCode();
            return hashCode;
        }

        public override string ToString()
        {
            return goods.ToString()+ $"，总金额：{money}";
        }
    }
}
